#include <bits/stdc++.h>
using namespace std;

string L(string str) {
    vector<int> cnt(10, 0);
    for (char c : str)
        cnt[c-'0']++;
    int odd = -1;
    for (int i = 0; i < 10; i++) {
        if (cnt[i] % 2) {
            if (odd != -1) return "";
            odd = i;
        }
    }
    string ans;
    for (int i = 9; i >= 0; i--) {
        for (int j = 0; j < cnt[i]/2; j++) {
            ans.push_back('0'+i);
        }
    }
    for (auto it = ans.rbegin(); it != ans.rend(); it++) {
        ans.push_back(*it);
    }
    if (odd != -1) {
        ans.insert(ans.begin()+ans.size()/2, 1, '0'+odd);
    }
    return ans;
}

int main() {
    assert(L("313551") == "531135");
    assert(L("331") == "313");
    assert(L("3444") == "");
    return 0;
}

